import request from '@/utils/request';

/**
 * 用户登录方法
 * @param username - 用户名
 * @param password - 密码
 * @param code - 验证码
 * @param uuid - 唯一标识符
 * @returns Promise<any>
 */
export function login(username: string, password: string, code: string, uuid: string): Promise<any> {
  const data = {
    username,
    password,
    code,
    uuid
  };
  return request({
    url: '/login',
    headers: {
      isToken: false
    },
    method: 'post',
    data
  });
}

/**
 * 用户注册方法
 * @param data - 注册数据
 * @returns Promise<any>
 */
export function register(data: any): Promise<any> {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data
  });
}

/**
 * 获取用户详细信息
 * @returns Promise<any>
 */
export function getInfo(): Promise<any> {
  return request({
    url: '/getInfo',
    method: 'get'
  });
}

/**
 * 用户退出登录
 * @returns Promise<any>
 */
export function logout(): Promise<any> {
  return request({
    url: '/logout',
    method: 'post'
  });
}

/**
 * 获取验证码图片
 * @returns Promise<any>
 */
export function getCodeImg(): Promise<any> {
  return request({
    url: '/captchaImage',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 3000
  });
}